home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / weapons / Push.lua < prev    next >
Text File  |  2010-08-31  |  2KB  |  58 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Push
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.push={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.push.gfx_wpn=loadgfx("weapons/push.bmp")                            -- Weapon Image
  13. setmidhandle(cc.push.gfx_wpn)
  14. cc.push.sfx_attack=loadsfx("throw.ogg")                                -- Attack Sound
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon: Push
  18. --------------------------------------------------------------------------------
  19.  
  20. cc.push.id=addweapon("cc.push","Push",cc.push.gfx_wpn)                -- Add Weapon
  21.  
  22. function cc.push.draw()                                                -- Draw
  23.     -- Decrease Timer (used for arm animation)
  24.     if weapon_timer>0.0 then
  25.         weapon_timer=weapon_timer-0.5
  26.     end
  27.     -- Draw
  28.     if getplayeraction(0)==0 then
  29.         setblend(blend_alpha)
  30.         setalpha(1)
  31.         setcolor(255,255,255)
  32.         setscale(-getplayerdirection(0),1)
  33.         setrotation(0)
  34.         drawimage(cc.push.gfx_wpn,getplayerx(0)+getplayerdirection(0)*(7+weapon_timer),getplayery(0)+5)
  35.     end
  36. end
  37.  
  38. function cc.push.attack(attack)                                        -- Attack
  39.     if (weapon_shots<=0) then
  40.         if (attack==1) then
  41.             -- No more weapon switching!
  42.             useweapon(0)
  43.             playsound(cc.push.sfx_attack)
  44.             weapon_shots=weapon_shots+1
  45.             -- Set timer for arm animation
  46.             weapon_timer=5
  47.             -- Collision
  48.             if collision(col10x10,getplayerx(0)+getplayerdirection(0)*23,getplayery(0)+5,0,1,0)==1 then
  49.                 if playercollision()~=0 and playercollision()~=playercurrent() then
  50.                     playerpush(playercollision(),getplayerdirection(0)*3,-2)
  51.                 end
  52.             end
  53.             -- End Turn
  54.             endturn()
  55.         end
  56.     end
  57. end
  58.